package org.iks.user.web.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.iks.user.web.entity.UserEntity;

/**
 * @author kzou
 * @date 2023/12/30 12:03
 * @description:
 */
@Data
@Schema(description = "用户信息")
@EqualsAndHashCode(callSuper = true)
public class UserInfoVo extends org.iks.common.pojo.user.UserInfoVo {

    @Schema(description = "用户ID")
    private Integer id;
    @Schema(description = "用户账号")
    private String account;

    @Schema(description = "用户头像地址")
    private String avatar;

    @Schema(description = "用户公钥")
    private String publicKey;

    @Schema(description = "用户昵称")
    private String name;

    public static UserInfoVo valueOf(UserEntity user) {
        if (user == null) return null;
        UserInfoVo result = new UserInfoVo();
        result.setId(user.getId());
        result.setAccount(user.getAccount());
        result.setAvatar(user.getAvatar());
        result.setName(user.getUsername());
        result.setPublicKey(user.getPublicAddress());
        return result;
    }

}
